package com.three.work.controller.app;


import com.three.work.controller.BaseController;
import org.springframework.web.bind.annotation.RequestMapping;
import com.three.work.bean.result.ResultPage;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ResponseBody;

import com.three.work.bean.Appuser;
import com.three.work.bean.result.ResultPage;
import com.three.work.controller.model.ApiResultModel;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 张子艺
 * @since 2020-04-02
 */
@Controller
@RequestMapping("/app/appuser")
public class AppuserController extends BaseController {
    /**
     * 主页面
     */
    @RequestMapping("main.html")
    public String main() {
        return "appuser/AppuserMain";
    }

    /**
     * 添加页面跳转
     *
     * @return 返回页面
     */
    @RequestMapping(value = "/addAppuserHtml")
    public String addAppuserHtml() {
        return "appuser/AppuserAdd";
    }

    /**
     * 编辑页面跳转
     *
     * @param id 前端传进的参数
     * @return 返回页面
     */
    @RequestMapping(value = "/editAppuserHtml")
    public String editAppuserHtml(Integer id, Model model) {
        model.addAttribute("appuser", appuserService.selectAppuserByIdAppuser(id));
        return "appuser/AppuserEdit";
    }

    /**
     * 查看页面跳转
     *
     * @param id 前端传进的参数
     * @return 返回页面
     */
    @RequestMapping(value = "/showAppuserHtml")
    public String showAppuserHtml(Integer id, Model model) {
        model.addAttribute("appuser", appuserService.selectAppuserByIdAppuser(id));
        return "appuser/AppuserShow";
    }


    /**
     * 分页查询Appuser
     *
     * @param page    页码
     * @param limit   查几条
     * @param appuser 前端传进的参数
     * @return 返回统一分页信息
     */
    @RequestMapping(value = "/findAppuserByPage")
    @ResponseBody
    public ResultPage findAppuserByPage(Integer page, Integer limit, Appuser appuser) {
        return appuserService.findAppuserByPage(page, limit, appuser);
    }

    /**
     * 添加Appuser
     *
     * @param appuser 前端传进的参数
     * @return 返回统一信息
     */
    @RequestMapping(value = "/addAppuser")
    @ResponseBody
    public ApiResultModel saveAppuser(Appuser appuser) {
        return appuserService.addAppuser(appuser);
    }

    /**
     * 编辑Appuser
     *
     * @param appuser 前端传进的参数
     * @return 返回统一信息
     */
    @RequestMapping(value = "/editAppuser")
    @ResponseBody
    public ApiResultModel editAppuser(Appuser appuser) {
        return appuserService.editAppuser(appuser);
    }


    /**
     * 删除一条Appuser
     *
     * @param id 前端传进的ID
     * @return 返回统一信息
     */
    @RequestMapping(value = "/delAppuser")
    @ResponseBody
    public ApiResultModel delAppuser(Integer id) {
        return appuserService.delAppuser(id);
    }


    /**
     * 查询审核成功的员工
     *
     * @return   返回所有审核中员工 state=2
     */
    @RequestMapping(value = "/getSuccessAppuser")
    @ResponseBody
    public ResultPage getSuccessAppser() {
        return appuserService.FindGetSuccessUser();
    }

    /**
     * 审核通过
     * @param id  要修改的用户的ID
     * @param state 当值为1的时候可以修改
     * @return
     */
    @RequestMapping(value="/updateUnderUser")
    @ResponseBody
    public ApiResultModel updateUnderUser(Integer id,Integer state){return appuserService.FindUpdateUnderUser(id,state);}

    /**
     * 查询所有审核中的人
     */
    @RequestMapping(value = "/getUnderUser")
    @ResponseBody
    public ResultPage getUnderUser() {
        return appuserService.FindGetUnderUser();
    }



}